<include file="Public/header"/>
<div class="comm-top">
    <div class="title-left">
        <h4 style="margin-bottom:0">登录
            <span style="font-size:12px;color:#aaa;font-weight:normal;"></span>
        </h4>
    </div>
    <div class="title-right"></div>
    <div class="add_page_top"></div>
</div>
<div class="login">
    <div class="sort_box">
        <div class="sort">
            <div class="sort_title"><h4>用户名：</h4></div>
            <div class="sort_set">
                <input class="sort_text" name="name" type="text" placeholder="用户名" />
            </div>
        </div>
        <div class="sort">
            <div class="sort_title"><h4>密码：</h4></div>
            <div class="sort_set">
                <input class="sort_text" name="pass" type="password" placeholder="密码" />
            </div>
        </div>
        <div class="sort">
            <div class="sort_title">
                <h4>&nbsp;</h4>
            </div>
            <div class="sort_set">
                <span onclick="login();return false" id="ts" class="btngreen30">登录</span>
                &nbsp;&nbsp;&nbsp;
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    function login() {
        var data = {};
        data.name = $('input[name="name"]').val();
        if (data.name == '') {
            layer.tips('用户名不能为空', 'input[name="name"]');
        }
        data.pass = $('input[name="pass"]').val();
        if (data.pass == '') {
            layer.tips('密码不能为空', 'input[name="pass"]');
        }
        $.ajax({
            url:'<{:U('login_do')}>',
            data:data,
            type:'post',
            dataType:'json',
            success:function(resp) {
                if (resp == null) {
                    return layer.alert("Error");
                }
                if (resp.status != null && resp.status == 0) {
                    layer.alert('登录成功');
                    window.location.href = '<{:U('index/index')}>';
                    return;
                } else {
                    if (typeof resp.info == 'string') {
                        return layer.alert(resp.info);
                    }
                }
                layer.alert("Error");
            }
        });
    }
</script>
<include file="Public/footer"/>